package bookstore;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * 注文データの月次の集計結果を表示するActionです
 */
public class ShowSumupAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws Exception {
        ServletContext context = getServlet().getServletContext();
        OrderManager manager = new OrderManager();
        request.setAttribute("sumupMap", manager.calculateMonthlyTotal(context));
        return mapping.findForward("success");
    }

}